const koa = require("koa");
// const router = require("koa-router");
const ip = require('ip')
const cors = require('koa2-cors');
const bodyParser = require("koa-bodyparser");
const koaBody = require('koa-body')
const path = require('path')
const app = new koa();
const _router = require('./router.js')
const routerResponse = require('./routerResponse')
const paramsVerify = require('./paramsVerify')
const authToken = require('./authToken.js')

require('./util/util.js')
// cors需要挂载在第一个，不然不生效
app.use(koaBody());
app.use(cors()).use(bodyParser()).use(routerResponse()).use(authToken()).use(paramsVerify()).use(_router.routes())
app.use(require('koa-static')('C:/Users/郭子文/Desktop/demo/node_admin/server' + '/public'))
app.listen(5000, function(){
    console.log("Server running on http://localhost:5000")
    console.log(ip.address()+':5000');
});